# -*- coding: utf-8 -*-
#
# PyRecorder
# Use PyHook and Pywin32 to recorder Keyboard&Mouse event

__author__ = "yisheng.tang"

import pythoncom
import pyHook
import win32api

def onMouseEvent(event):

    print "MessageName:", event.MessageName
    print "Message", event.Message
    print "Time", event.Time
    print "Window", event.Window
    print "WindowName:", event.WindowName     
    print "Position:", event.Position     
    print "Wheel:", event.Wheel     
    print "Injected:", event.Injected           
    print"---"

    return True

def onMouseLeftClick(event):

    global Msg

    if event.Message == 513:
        print "MessageName:", event.MessageName
    if event.Message == 519:
        print "User break"
        quit()

    return True


def main():

    Msg = ''

    hm = pyHook.HookManager()

    hm.MouseAll = onMouseLeftClick
    hm.HookMouse()
    pythoncom.PumpMessages()

if __name__ == '__main__':
    main()